<?php

	require_once "weixin_info.php";
	require_once "config.php";
    $id = !empty($_GET['id']) ? $_GET['id'] : '0';
    $lng = !empty($_GET['lng']) ? $_GET['lng'] : '';
    $lat = !empty($_GET['lat']) ? $_GET['lat'] : '';
    $name = !empty($_GET['name']) ? $_GET['name'] : '';
	$goods_sql = $mysql->query("select * from dyspw_goods where u_id = $id  ORDER BY time ");//è§†é¢‘

	$goods_list = $goods_sql->fetch_all(MYSQLI_ASSOC);
	if($goods_list){
        $merchantInfo = $mysql->query('select industry_type,sort from dyspw_member  where id = '.$id.' and is_vip = 3 and sort = 92');
        $merchantInfo = $merchantInfo->fetch_assoc();
        if($merchantInfo && $merchantInfo['industry_type']){
            header("Location: delivery_center.php?id=".$id);
        }
    }
    // print_r($goods_list);exit;
	require_once "jssdk.php";
	$jssdk = new JSSDK();
	$signPackage = $jssdk->GetSignPackage();
 ?>

<!DOCTYPE html>

<html>



<head>

	<meta charset="utf-8">

	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

	<title>商品列表</title>

	<script src="js/mui.min.js"></script>
    <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="//webapi.amap.com/maps?v=1.4.1&key=fedad41056b27c3e8cc5eaca216434e9"></script>
	<script src="js/dsbridge.js" type="text/javascript"></script>
	<link href="css/mui.min.css" rel="stylesheet" />
	<link href="css/index.css" rel="stylesheet" />
	<link rel="stylesheet" href="css/core.css">
	<style>
		.cardList img{
			max-width: 100%;
			height: 250px;
		}

		.search{
			display: flex;
    		align-items: center;
			line-height: 0;
		}

		.search .mui-input-clear{
			line-height: 0;
    		height: 34px;
		}
	</style>

	<script type="text/javascript" charset="utf-8">

		mui.init();

	</script>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
</head>



<body>

	<div class="container" style="margin-bottom: 40px;">

		<div class="top">

			<div class="header mui-row">

				<div class="left mui-col-xs-6">

					<span class="mui-icon mui-icon-arrowleft" onclick="goindex()"></span>

					<img src="./images/logo.gif" alt="">

					<span class="title">生活</span>

				</div>

				<div class="location mui-col-xs-6" onclick="getLo();">

					<img src="./images/loc .gif" alt="">

					<div class="address mui-ellipsis">苏州中心商场C座</div>

					<span class="mui-icon mui-icon-arrowright"></span>

				</div>

			</div>



			<!-- 轮播 -->

		</div>



		<!-- 栏目column -->





		<!-- 产品列表 -->

		<div class="dataList">

			<div class="cardList">

				<?php if(!empty($goods_list)){foreach ($goods_list as $key => $val) {?>

					<div class="mui-card cardItem">

						<a href="goods_info.php?id=<?php echo $val['id']; ?>">

							<div class="mui-card-content" style="background:url(<?php echo $val['img'] ?>)no-repeat center;background-size: 100% auto;width: 100%;height: 130px;">

								<!-- <img src="<?php echo $val['img'] ?>" alt="" class="itemImg"> -->

							</div>

							<div class="mui-card-footer mui-row">

								<div class="title mui-ellipsis mui-col-xs-12"><?php echo $val['title'] ?></div>

								<div class="desc mui-ellipsis mui-col-xs-12"><?php echo $val['details'] ?></div>

								<div class="data mui-col-xs-12">

									<div class="price"><span class="num">团购价:¥<?php
									if(empty($val['group_money'])){ echo $val['money']; }else{echo $val['group_money'];}  ?><em style="    color: #999;font-size: 10px;margin-left: 5px;">原价:￥<?php echo $val['money']; ?></em></span></div>

									<div class="salseNum">已售2份</div>

								</div>

							</div>

						</a>

					</div>

				<?php }}else{?>
                    <p style="display: inline-block;width: 80%;margin: auto;text-align: center;line-height: 50px;font-size: 14px;margin-top: 50px;    margin-left: 10%;background: #eee;border-radius: 10px;letter-spacing: 2px;">暂无商品</p>
                <?php } ?>



				<!-- <div class="mui-card cardItem">

					<div class="mui-card-content">

						<img src="./images/pd2.jpg" alt="" class="itemImg">

					</div>

					<div class="mui-card-footer mui-row">

						<div class="title mui-ellipsis mui-col-xs-12">美食名称-白色爱琴海</div>

						<div class="desc mui-ellipsis mui-col-xs-12">欧式风格:浪漫艺术与生活品质的追求</div>

						<div class="data mui-col-xs-12">

							<div class="price">¥<span class="num">999</span>/平</div>

							<div class="salseNum">已售3份</div>

						</div>

					</div>

				</div>



				<div class="mui-card cardItem">

					<div class="mui-card-content">

						<img src="./images/pd2.jpg" alt="" class="itemImg">

					</div>

					<div class="mui-card-footer mui-row">

						<div class="title mui-ellipsis mui-col-xs-12">美食名称-白色爱琴海</div>

						<div class="desc mui-ellipsis mui-col-xs-12">欧式风格:浪漫艺术与生活品质的追求</div>

						<div class="data mui-col-xs-12">

							<div class="price">¥<span class="num">999</span>/平</div>

							<div class="salseNum">已售3份</div>

						</div>

					</div>

				</div> -->

			</div>

		</div>

	</div>

	<footer>

	    <ul class="cl">

	        <li><a href="index.php">首页</a></li>

	        <li><a href="fenlei.php">分类</a></li>

	        <li>

	            <a href="baishe.php" class="btn-baise">拍</a>

	        </li>

	        <li><a href="shopping.php">商城</a></li>

	        <li><a href="member.php">我</a></li>

	    </ul>

	</footer>



	<!-- 模板引擎 -->

	<!-- <script type="text/html" id="tpl">

		{{ each items v i }}

		<div class="mui-card">

			<div class="mui-card-content">

				<img src="{{ v }}" alt="" class="itemImg">

			</div>

			<div class="mui-card-footer mui-row">

				<div class="title mui-ellipsis mui-col-xs-12">强化地板-白色爱琴海</div>

				<div class="desc mui-ellipsis mui-col-xs-12">欧式风格:浪漫艺术与生活品质的追求</div>

				<div class="data mui-col-xs-12">

					<div class="price">¥<span class="num">999</span>/平</div>

					<div class="salseNum">已售2份</div>

				</div>

			</div>

		</div>

		{{ /each }}

	</script> -->

	<script src="js/jquery-2.2.4.min.js"></script>

	<script src="js/jquery.waterfall.js"></script>

	<script src="js/template-web.js"></script>
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

	<script>

		$(function () {

			render()

			wx.config({
				debug: false,
				appId: '<?php echo $signPackage["appId"];?>' ,
				timestamp: <?php echo $signPackage["timestamp"];?>,
				nonceStr: '<?php echo $signPackage["nonceStr"];?>',
				signature: '<?php echo $signPackage["signature"];?>',
				jsApiList: [
					'previewImage', 'openLocation', 'getLocation',
					'checkJsApi',
					'scanQRCode',
				]
			});
			wx.error(function(res) {
				alert("出错了：" + res.errMsg); //这个地方的好处就是wx.config配置错误，会弹出窗口哪里错误，然后根据微信文档查询即可。
			});


			function render() {

				// var dataList = ["./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg",

				// 	"./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg",

				// 	"./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg", "./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg",

				// 	"./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg", "./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg",

				// 	"./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg", "./images/9965de69c69b70d0dab1bb65cd5dc62e.jpg",

				// ]

				// var htmlStr = template("tpl", dataList);

				// $('.cardList').append(htmlStr);

				$('.cardList').waterFall();



				// var gallery = mui('.mui-slider');

				// gallery.slider({

				// 	interval: 1000 //自动轮播周期，若为0则不自动播放，默认为0；

				// });

			}

		})

	function goindex(){
		window.location.href='https://5p8.fyh5p8.com/xiaochengxu/index.php';
	}

	function toScan(){
        wx.ready(function() {
            wx.checkJsApi({
                jsApiList: ['scanQRCode'],
                success: function(res) {
                    console.log('扫一扫：',res)
                }
            });

            wx.scanQRCode({
                needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                success: function(res) {
                    var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                    // alert(result)
                    // $.ajax({
                    //     url: result,
                    //     dataType: 'json',
                    //     type:'get',
                    //     data:{"shop_id":_shopid},
                    //     success:function(res){
                    //         layer.open({content: res.msg,skin: 'msg',time: 3 });
                    //     },
                    //     error:function(){
                    //         //请求出错处理
                    //     }
                    // })
                },
                error: function(res) {
                    alert(res)
                }
            });
        });
    }

	function getLo(){
		var lng = "<?php echo $lng; ?>";
		var lat = "<?php echo $lat; ?>";
		var name = "<?php echo $name; ?>";
		if(window.navigator.userAgent == 'AndroidNative'){
			// javascript:android.mapSite();
			dsBridge.call("mapSite", {lng: lng, lat: lat, name: name});
		} else if (window.navigator.userAgent == 'IosNative') {
			// window.webkit.messageHandlers.mapSite.postMessage({});
			dsBridge.call("mapSite", {lng: lng, lat: lat, name: name});
		} else {
			wx.ready(function () {
				wx.getLocation({
					type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
					success: function (res) {
						//使用微信内置地图查看位置接口
						wx.openLocation({
							latitude : lat, // 纬度，浮点数，范围为90 ~ -90
							longitude : lng, // 经度，浮点数，范围为180 ~ -180。
							// latitude : res.latitude, // 纬度，浮点数，范围为90 ~ -90
							// longitude : res.longitude, // 经度，浮点数，范围为180 ~ -180。
							name : name, // 位置名
							//address : '5pai8社区', // 地址详情说明
							scale : 28, // 地图缩放级别,整形值,范围从1~28。默认为最大
							//infoUrl : 'http://www.gongjuji.net' // 在查看位置界面底部显示的超链接,可点击跳转（测试好像不可用）
						});

					},
					cancel: function (res) {
						layer.open({
							content: '您拒绝授权获取地理位置',
							btn: '我知道了'
						});

					},
					fail: function (res) {
						// alert('fail'+JSON.stringify(res));
						layer.open({
							content: '未能获取地理位置，首先检查手机是否启用微信定位',
							btn: '我知道了'
						});
					}
				});
				wx.error(function (res) {
					layer.open({
						content: 'error接口调取失败！请联系技术部' + JSON.stringify(
							res),
						btn: '我知道了'
					});
				});
			});
		}

	}

    //获取当前位置信息
    function getaddre() {
        var map, geolocation;
        map = new AMap.Map('allmap');
        map.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true //是否使用高精度定位，默认:true
            });
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', function (point) {
                var lnglatXY = [point.position.lng, point.position.lat]; //已知点坐标
				map.plugin('AMap.Geocoder', function() {
					var geocoder = new AMap.Geocoder();
					geocoder.getAddress(lnglatXY, function(status, result) {
						if (status === 'complete' && result.info === 'OK') {
							var address = result.regeocode.formattedAddress;
							var obj = result.regeocode.addressComponent;
							address = address.replace(obj.province, '');
							address = address.replace(obj.district, '');
							address = address.replace(obj.city, '');
                            $(".address").html(address);
						}
					});
				});
            });
        });
    }
    getaddre();
	</script>

</body>



</html>
